package org.UDPcommunication;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class MulticastSendMessageDemo {
    public static void main(String[] args) throws IOException {
        MulticastSocket multicastSocket=new MulticastSocket();
        String data="组播数据传输案例";
        byte[] bytes = data.getBytes();

        InetAddress byName = InetAddress.getByName("224.0.0.1");

        DatagramPacket datagramPacket=new DatagramPacket(bytes,bytes.length,byName,10000);
        multicastSocket.send(datagramPacket);
        multicastSocket.close();
    }
}
